{template 'public/header'}
{template 'public/comhead'}
<link href="{$_W['siteroot']}addons/weisrc_dish/plugin/gritter/jquery.gritter.css" rel="stylesheet">
<script src="{$_W['siteroot']}addons/weisrc_dish/plugin/gritter/jquery.gritter.min.js"></script>
<link rel="stylesheet" href="{$_W['siteroot']}addons/weisrc_dish/public/web/css/back.css">
<link rel="stylesheet" href="{$_W['siteroot']}addons/weisrc_dish/public/web/css/style.css?v=1.2">
<script src="{$_W['siteroot']}addons/weisrc_dish/public/web/js/jquery.flot.js?v=2.1.4"></script>
<script src="{$_W['siteroot']}addons/weisrc_dish/public/web/js/echarts-all.js?v=2.1.4"></script>
<style>
    .clearfix .row{
        margin-left: -15px;
        margin-right: -15px;
    }
</style>
<ul class="nav nav-tabs">
    <li {if $operation == 'display'}class="active"{/if}><a
        href="{php echo $this->createWebUrl('financestatis', array('op' => 'display'))}">平台交易流水报表</a></li>
    <li {if $operation == 'shop'}class="active"{/if}><a
        href="{php echo $this->createWebUrl('financestatis', array('op' => 'shop'))}">商户日交易报表</a></li>
    <li {if $operation == 'marketing'}class="active"{/if}><a
        href="{php echo $this->createWebUrl('financestatis', array('op' => 'marketing'))}">市场经理提成报表</a></li>
    <li {if $operation == 'main'}class="active"{/if}><a
        href="{php echo $this->createWebUrl('financestatis', array('op' => 'main'))}">平台利润</a></li>
</ul>

{if $operation == 'display'}
<div class="clearfix">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title" style="border-color: #e7eaec;border-style: solid solid none;"><h5>筛选</h5>
                </div>
                <div class="ibox-content">
                    <form action="" method="get" class="form-horizontal" role="form" id="list">
                        <input type="hidden" name="c" value="site">
                        <input type="hidden" name="a" value="entry">
                        <input type="hidden" name="m" value="weisrc_dish">
                        <input type="hidden" name="do" value="financestatis"/>
                        <input type="hidden" name="op" value="display"/>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">所属门店</label>
                            <div class="col-sm-7 col-lg-2 col-xs-12">
                                <select name="storeid" class="form-control">
                                    <option value="">全部门店</option>
                                    {loop $storelist $row}
                                    <option value="{$row['id']}"{if $storeid==$row['id']} selected{/if}>{$row['title']}</option>
                                    {/loop}
                                </select>
                            </div>
                        </div>
                        <div class="form-group clearfix">
                            <label class="col-xs-12 col-sm-2 col-md-1 control-label">时间范围</label>

                            <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
                                {php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:i:s',$starttime),'endtime'=>date('Y-m-d H:i:s', $endtime)), true);}
                                <input class="btn btn-sm btn-success" name="commit" type="submit" value="搜索">
                                <button class="btn btn-sm btn-success" name="out_put" value="output"><i
                                        class="fa fa-file"></i> 导出</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
    <form class="form-horizontal" action="" method="post" onkeydown="if(event.keyCode == 13) return false;">
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-hover table-bordered table-text-center">
                        <thead class="navbar-inner">
                        <tr>
                            <th width="300">时间</th>
                            <th>营业额</th>
                            <th>订单数</th>
                            <th>余额支付</th>
                            <th>微信支付</th>
                            <th>支付宝</th>
                            <th>现金支付</th>
                            <!--<th>查看详情</th>-->
                        </tr>
                        </thead>
                        <tfoot>
                        <tr>
                            <th width="300">总计</th>
                            <th>{php echo sprintf('%.3f', $footer_totalprice);}{$setting['currency']}</th>
                            <th>{php echo intval($footer_totalcount);}单</th>
                            <th>{php echo sprintf('%.3f', $footer_totalprice1);}{$setting['currency']}</th>
                            <th>{php echo sprintf('%.3f', $footer_totalprice2);}{$setting['currency']}</th>
                            <th>{php echo sprintf('%.3f', $footer_totalprice4);}{$setting['currency']}</th>
                            <th>{php echo sprintf('%.3f', $footer_totalprice3);}{$setting['currency']}</th>
                            <!--<th>查看详情</th>-->
                        </tr>
                        </tfoot>
                        <tbody>
                        {loop $return $k $row}
                        <tr>
                            <th>{$k}</th>
                            <td>{php echo sprintf('%.3f', $row['totalprice']);}{$setting['currency']}</td>
                            <td>{php echo intval($row['count']);} 单</td>
                            <td>{php echo sprintf('%.3f', $row['1']);}{$setting['currency']}</td>
                            <td>{php echo sprintf('%.3f', $row['2']);}{$setting['currency']}</td>
                            <td>{php echo sprintf('%.3f', $row['4']);}{$setting['currency']}</td>
                            <td>{php echo sprintf('%.3f', $row['3']);}{$setting['currency']}</td>
                            <!--<td>-->
                            <!--<a href="#" class="btn btn-success" target="_blank">详情</a>-->
                            <!--</td>-->
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </form>
</div>
{elseif $operation == 'shop'}
<div class="clearfix">
    {if $_GPC['ac'] != 'detail'}
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title" style="border-color: #e7eaec;border-style: solid solid none;"><h5>筛选</h5>
                </div>
                <div class="ibox-content">
                    <form action="" method="get" class="form-horizontal" role="form">
                        <input type="hidden" name="c" value="site">
                        <input type="hidden" name="a" value="entry">
                        <input type="hidden" name="m" value="weisrc_dish">
                        <input type="hidden" name="do" value="financestatis"/>
                        <input type="hidden" name="op" value="shop"/>
                        <div class="form-group clearfix">
                            <label class="col-xs-12 col-sm-2 col-md-1 control-label">时间</label>
                            <div class="col-sm-7 col-lg-2 col-xs-12">
                                {php echo tpl_form_field_date('time', date('Y-m-d',$starttime), false);}
                            </div>
                            <div class="col-sm-7 col-lg-4 col-xs-12">
                                <input class="btn btn-sm btn-success" name="commit" type="submit" value="搜索">
                                <button class="btn btn-sm btn-success" name="out_put" value="output"><i class="fa fa-file"></i> 导出</button>
                                <button class="btn btn-sm btn-success" name="ac" value="checkall">一键打款</button>

                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    {/if}
    <form class="form-horizontal" action="" method="post">
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="table-responsive">
                    {if $_GPC['ac'] == 'detail'}
                    <table class="table table-hover table-bordered table-text-center">
                        <thead class="navbar-inner">
                        <tr>
                            <th>订单号</th>
                            <th>总金额</th>
                            <th>状态</th>
                            <th>支付状态</th>
                            <th>下单时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $list $key $row}
                        <tr>
                            <th>{$row['ordersn']}</th>
                            <td>
                                {php echo sprintf('%.3f', $row['totalprice']);} {$setting['currency']}
                            </td>
                            <td>
                                {if $row['status'] == 0}<span class="label label-info">待处理</span>{/if}
                                {if $row['status'] == 1}<span class="label label-warning">已确认</span>{/if}
                                {if $row['status'] == 2}<span class="label label-success">已并台</span>{/if}
                                {if $row['status'] == 3}<span class="label label-success">已完成</span>{/if}
                                {if $row['status'] == -1}<span class="label label-danger">已取消</span>{/if}
                            </td>
                            <td>
                                {if $row['paytype']}
                                {if $row['paytype'] == 1}
                                <span class="label label-success"><i class="fa fa-money">&nbsp;余额支付</i></span>
                                {/if}
                                {if $row['paytype'] == 2}
                                <span class="label label-success"><i class="fa fa-check-circle">&nbsp;微信支付</i></span>
                                {/if}
                                {if $row['paytype'] == 3}
                                <span class="label label-success"><i class="fa fa-money">&nbsp;现金支付</i></span>
                                {/if}
                                {if $row['paytype'] == 4}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;支付宝</i></span>
                                {/if}
                                {if $row['paytype'] == 5}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;现金</i></span>
                                {/if}
                                {if $row['paytype'] == 6}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;银行卡</i></span>
                                {/if}
                                {if $row['paytype'] == 7}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;会员卡</i></span>
                                {/if}
                                {if $row['paytype'] == 8}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;微信记账</i></span>
                                {/if}
                                {if $row['paytype'] == 9}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;支付宝记账</i></span>
                                {/if}
                                {if $row['paytype'] == 10}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;pos刷卡</i></span>
                                {/if}
                                {if $row['paytype'] == 11}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;挂帐</i></span>
                                {/if}
                                <br/>
                                {/if}
                                {if $row['ispay'] == 0}<span class="label label-warning">未支付</span>{/if}
                                {if $row['ispay'] == 1}<span class="label label-success"><i class="fa fa-cloud">已支付</i></span>{/if}
                            </td>
                            <td>
                                {php echo date("Y-m-d H:i:s", $row['dateline'])}
                            </td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                    {else}
                    <table class="table table-hover table-bordered table-text-center">
                        <thead class="navbar-inner">
                        <tr>
                            <th>门店名称</th>
                            <th>日营业额(在线支付)</th>
                            <th>门店费率</th>
                            <th>结算金额</th>
                            <th width="300">银行资料</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $list $key $row}
                        <tr>
                            <th>{$row['title']}</th>
                            <td>
                                {php echo sprintf('%.3f', $row['totalprice']);}{$setting['currency']}
                                <a href="{php echo $this->createWebUrl('financestatis', array('op' => 'shop', 'ac' => 'detail', 'date' => $selecttime, 'storeid' => $row['id']))}" title="审核" style="color: #3296fa;"> 详情</a>
                            </td>
                            <td>
                                {if $row['is_default_rate']==1}
                                {php $show_fee_rate = intval($setting['fee_rate'])}
                                {else}
                                {php $show_fee_rate = intval($row['fee_rate'])}
                                {/if}
                                {$show_fee_rate}%
                            </td>
                            <td>
                                {php $fee= floatval($row['totalprice'])*floatval($show_fee_rate)/100;}
                                {php echo $row['totalprice']-$fee;} {$setting['currency']}
                            </td>
                            <td style="text-align: left;">卡号：{$row['business_bankcard']}
                                <br/>
                                姓名：{$row['business_username']}
                            </td>
                            <td>
                                {if !empty($loglist[$row['id']])}
                                <span class="label label-success">已打款</span>
                                {else}
                                <span class="label label-danger">未打款</span>
                                <a class="btn btn-success btn-sm"
                                   href="{php echo $this->createWebUrl('financestatis', array('op' => 'shop', 'ac' => 'check', 'date' => $selecttime, 'logid' => $row['id']))}" title="审核" onclick="return confirm('确认操作吗？');return false;"> 打款</a>
                                {/if}

                            </td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                    {/if}
                </div>
            </div>
        </div>
    </form>
</div>
{elseif $operation == 'marketing'}
<div class="clearfix">
    {if $_GPC['ac'] != 'detail'}
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title" style="border-color: #e7eaec;border-style: solid solid none;"><h5>筛选</h5>
                </div>
                <div class="ibox-content">
                    <form action="" method="get" class="form-horizontal" role="form">
                        <input type="hidden" name="c" value="site">
                        <input type="hidden" name="a" value="entry">
                        <input type="hidden" name="m" value="weisrc_dish">
                        <input type="hidden" name="do" value="financestatis"/>
                        <input type="hidden" name="op" value="marketing"/>
                        <div class="form-group clearfix">
                            <label class="col-xs-12 col-sm-2 col-md-1 control-label">时间范围</label>
                            <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
                                {php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:i:s',$starttime),'endtime'=>date('Y-m-d H:i:s', $endtime)), true);}<input class="btn btn-sm btn-success" name="commit" type="submit" value="搜索">
                                <button class="btn btn-sm btn-success" name="out_put" value="output"><i
                                        class="fa fa-file"></i> 导出</button>
                                <!--<button class="btn btn-sm btn-success" name="ac" value="checkall">一键打款</button>-->
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    {/if}
    <form class="form-horizontal" action="" method="post">
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="table-responsive">
                    {if $_GPC['ac'] == 'detail'}
                    <table class="table table-hover table-bordered table-text-center" style="display: none;">
                        <thead class="navbar-inner">
                        <tr>
                            <th>订单号</th>
                            <th>总金额</th>
                            <th>状态</th>
                            <th>支付状态</th>
                            <th>下单时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $list $key $row}
                        <tr>
                            <th>{$row['ordersn']}</th>
                            <td>
                                {php echo sprintf('%.3f', $row['totalprice']);} {$setting['currency']}
                            </td>
                            <td>
                                {if $row['status'] == 0}<span class="label label-info">待处理</span>{/if}
                                {if $row['status'] == 1}<span class="label label-warning">已确认</span>{/if}
                                {if $row['status'] == 2}<span class="label label-success">已并台</span>{/if}
                                {if $row['status'] == 3}<span class="label label-success">已完成</span>{/if}
                                {if $row['status'] == -1}<span class="label label-danger">已取消</span>{/if}
                            </td>
                            <td>
                                {if $row['paytype']}
                                {if $row['paytype'] == 1}
                                <span class="label label-success"><i class="fa fa-money">&nbsp;余额支付</i></span>
                                {/if}
                                {if $row['paytype'] == 2}
                                <span class="label label-success"><i class="fa fa-check-circle">&nbsp;微信支付</i></span>
                                {/if}
                                {if $row['paytype'] == 3}
                                <span class="label label-success"><i class="fa fa-money">&nbsp;现金支付</i></span>
                                {/if}
                                {if $row['paytype'] == 4}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;支付宝</i></span>
                                {/if}
                                {if $row['paytype'] == 5}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;现金</i></span>
                                {/if}
                                {if $row['paytype'] == 6}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;银行卡</i></span>
                                {/if}
                                {if $row['paytype'] == 7}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;会员卡</i></span>
                                {/if}
                                {if $row['paytype'] == 8}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;微信记账</i></span>
                                {/if}
                                {if $row['paytype'] == 9}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;支付宝记账</i></span>
                                {/if}
                                {if $row['paytype'] == 10}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;pos刷卡</i></span>
                                {/if}
                                {if $row['paytype'] == 11}
                                <span class="label label-info"><i class="fa fa-alipay">&nbsp;挂帐</i></span>
                                {/if}
                                <br/>
                                {/if}
                                {if $row['ispay'] == 0}<span class="label label-warning">未支付</span>{/if}
                                {if $row['ispay'] == 1}<span class="label label-success"><i class="fa fa-cloud">已支付</i></span>{/if}
                            </td>
                            <td>
                                {php echo date("Y-m-d H:i:s", $row['dateline'])}
                            </td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                    <table class="table table-hover table-bordered table-text-center">
                        <thead class="navbar-inner">
                        <tr>
                            <th>门店名称</th>
                            <th>营业额(在线支付)</th>
                            <th>佣金</th>
                            <th width="300">银行资料</th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $list $key $row}
                        <tr>
                            <th>{$row['title']}</th>
                            <td>
                                {php echo sprintf('%.3f', $row['totalprice']);}{$setting['currency']}
                            </td>
                            <td>
                                {php echo sprintf('%.3f', $row['marketingprice']);}{$setting['currency']}
                            </td>
                            <td style="text-align: left;">卡号：{$row['business_bankcard']}
                                <br/>
                                姓名：{$row['business_username']}
                            </td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                    {else}
                    <table class="table table-hover table-bordered table-text-center">
                        <thead class="navbar-inner">
                        <tr>
                            <th>市场专员</th>
                            <th>营业额</th>
                            <th>累计佣金</th>
                            <th>提成比例</th>
                            <th>提成金额</th>
                            <th width="300">银行资料</th>
                            <!--<th>操作</th>-->
                        </tr>
                        </thead>
                        <tbody>
                        {loop $list $key $row}
                        <tr>
                            <td>{$row['username']}</td>
                            <td>{php echo sprintf('%.3f', $row['totalprice']);}{$setting['currency']}
                                <a href="{php echo $this->createWebUrl('financestatis', array('op' => 'marketing', 'ac' => 'detail', 'starttime' => $starttime, 'marketingid' => $row['id'], 'endtime' => $endtime))}" title="审核" style="color: #3296fa;"> 详情</a>
                            </td>
                            <td>
                                {php echo sprintf('%.3f', $row['allmarketingprice']);}{$setting['currency']}
                            </td>
                            <td>
                                {$row['fee_rate']}%
                            </td>
                            <td>{php echo sprintf('%.3f', $row['marketingprice']);} {$setting['currency']}</td>
                            <td style="text-align: left;">卡号：{$row['bankcard']}
                                <br/>
                                姓名：{$row['username']}
                            </td>
                            <!--<td>-->
                                <!--{if !empty($loglist[$row['id']])}-->
                                <!--<span class="label label-success">已打款</span>-->
                                <!--{else}-->
                                <!--<span class="label label-danger">未打款</span>-->
                                <!--<a class="btn btn-success btn-sm"-->
                                   <!--href="{php echo $this->createWebUrl('financestatis', array('op' => 'marketing', 'ac' => 'check', 'date' => $selecttime, 'logid' => $row['id']))}" title="审核" onclick="return confirm('确认操作吗？');return false;"> 打款</a>-->
                                <!--{/if}-->

                            <!--</td>-->
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                    {/if}
                </div>
            </div>
        </div>
    </form>
</div>


{elseif $operation == 'main'}

<div class="clearfix">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title" style="border-color: #e7eaec;border-style: solid solid none;"><h5>筛选</h5>
                </div>
                <div class="ibox-content">
                    <form action="" method="get" class="form-horizontal" role="form">
                        <input type="hidden" name="c" value="site">
                        <input type="hidden" name="a" value="entry">
                        <input type="hidden" name="m" value="weisrc_dish">
                        <input type="hidden" name="do" value="financestatis"/>
                        <input type="hidden" name="op" value="main"/>
                        <div class="form-group clearfix">
                            <label class="col-xs-12 col-sm-2 col-md-1 control-label">时间范围</label>
                            <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
                                {php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:i:s',$starttime),'endtime'=>date('Y-m-d H:i:s', $endtime)), true);}<input class="btn btn-sm btn-success" name="commit" type="submit" value="搜索">
                                <button class="btn btn-sm btn-success" name="out_put" value="output"><i
                                        class="fa fa-file"></i> 导出</button>
                            </div>

                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <form class="form-horizontal" action="" method="post" onkeydown="if(event.keyCode == 13) return false;">
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-hover table-bordered table-text-center">
                        <thead class="navbar-inner">
                        <tr>
                            <th width="300">门店名称</th>
                            <th>营业额</th>
                            <th>平台抽佣金额</th>
                            <th>支付通道费</th>
                            <th>经理提成利润</th>
                            <th>平台利润</th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $list $key $row}
                        <tr>
                            <th>{$row['title']}</th>
                            <td>{php echo sprintf('%.3f', $row['totalprice']);} {$setting['currency']}</td>
                            <td>
                                {$row['fee_price']}
                            </td>
                            <td>
                                {$row['payment_price']}
                            </td>
                            <td>{$row['marketingprice']} </td>
                            <td>{$row['price']} </td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </form>
</div>
{/if}
{if $_W['isfounder']}
<style>
    .footer{
        height: 100%;
    }
</style>
{template 'common/footer'}
{else}
{template 'public/footer'}
{/if}